home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZWindow.h -- the window object
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
- #pragma once
-
- #ifndef __ZWINDOW__
- #define __ZWINDOW__
-
- #ifndef __ZCOMMANDER__
- #include "ZCommander.h"
- #endif
-
- class ZUndoTask;
-
- class ZWindow : public ZCommander
- {
- protected:
- Rect sizeRect; // min and max sizes for window
- WindowPtr macWindow; // the mac window associated with this object
- short windID; // res ID of 'WIND' template
- Boolean dirty; // TRUE if window needs to be saved
- Boolean isNamed; // TRUE if window has a name other than "untitled"
- FSSpec macFile; // the file that corresponds to this window
- OSType macFType; // file type last opened
- Boolean printable; // TRUE if this window can be printed (default FALSE)
- Boolean isPrinting; // TRUE if draw operation is to printer
- Boolean floating; // TRUE if this is a floating window
- Boolean disableAutoClose; // if TRUE, this window is skipped during Quit or Close All
-
- public:
- ZWindow( ZCommander* aBoss, const short windowID );
- virtual ~ZWindow();
-
- // initialisation (MUST be called after construction)
- virtual void InitZWindow();
-
- // drawing and clicking
- virtual void Focus();
- virtual void Draw();
- virtual void DrawGrow();
- virtual void DrawContent();
- virtual void Click( const Point mouse, const short modifiers);
- virtual void AdjustCursor( const Point mouse, const short modifiers);
- virtual void PostRefresh();
- virtual Boolean ClickInSamePlace( const Point click1, const Point click2 );
-
- // window state manipulation
- virtual void Hide();
- virtual void Show();
- virtual void Select();
- virtual void Activate();
- virtual void Deactivate();
- virtual Boolean Close( const short phase );
- virtual Boolean CloseSubsidiaryWindows( const short phase );
-
- // command handling
- virtual void HandleCommand( const long aCmd );
- virtual void HandleCommand( const short menuID, const short itemID );
- virtual void UpdateMenus();
- virtual void SetTask( ZUndoTask* aTask );
-
- // sizing and zooming
- virtual void SetSizeRect( const Rect& szRect );
- virtual void GetSizeRect( Rect* szRect );
- virtual void Zoom( const short partCode );
- virtual void PlaceAt( const short hGlobal, const short vGlobal );
- virtual void SetSize( const short width, const short height, const Boolean reDraw );
- virtual void SetSize( const short width, const short height ) { SetSize(width, height, TRUE); };
- virtual void SetStdZoomRect( const Rect& aRect );
-
- // file handling
- virtual Boolean Save( const Boolean forceSaveAs = FALSE );
- virtual void SaveFile();
- virtual void Revert();
- virtual void SetFile( const FSSpec& aFile );
- virtual void OpenFile( const OSType aFileType );
- virtual void PickFile( StandardFileReply* macReply );
-
- // print handling
- virtual void CalcPages( const Rect& paperRect, short* pagesH, short* pagesV );
- virtual void PrintOnePage( const short pageNum, const Rect& paperRect );
- virtual void PrintingStarting() { isPrinting = TRUE; };
- virtual void PrintingFinishing() { isPrinting = FALSE; };
-
- inline Boolean IsPrintable() { return printable; };
-
- // other info
- virtual void SetTitle( Str255 aTitle );
- virtual void GetName( Str255 name );
- virtual void GetContentRect( Rect* contents );
- virtual void GetBounds( Rect* aBounds ) { GetContentRect( aBounds ); };
- virtual Boolean IsVisible();
-
- // positioning and frame info:
- virtual short GetTitleBarHeight();
- virtual void GetStructureRegion( RgnHandle aRgn );
- virtual void GetContentRegion( RgnHandle aRgn );
- virtual void GetStructureFrameBorder( Rect* aRect );
- virtual void GetGlobalPosition( short* hGlobal, short* vGlobal );
-
- virtual ZCommander* GetHandler();
-
- inline WindowPtr GetMacWindow(){ return macWindow; };
- inline Boolean Floats() { return floating; };
- inline Boolean NoAutoClose() { return disableAutoClose; };
- inline void GetFileSpec( FSSpec* aSpec ) { *aSpec = macFile; };
- inline Boolean IsDirty() { return dirty; };
- inline void SetDirty( Boolean dState ) { dirty = dState; };
-
- protected:
-
- virtual void MakeMacWindow( const short windID );
-
- };
-
-
-
- #define kNoFile -9999
- #define kRevertConfirmAlertID 135
-
-
- /*
-
- ZWindows manage Mac windows. The refCon of a macWindow in Object MacZapp is the object
- reference. This class handles all types of non-dialog windows. For dialogs, use ZDialog,
- which is a subclass of this. A ZWindow is really equivalent to a document, since it has
- methods for reading and writing its contents to files. However, you can ignore this
- facility for non-document windows. This approach simplifies the framework, since you don't
- need separate classes for different types of windows.
-
- */
-
-
- #define kInfinityWindoidDefinition 128
-
- // structure of "WIND' resource- we take a peek here ourselves to determine if the
- // window is a floater or not
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
-
- typedef struct
- {
- Rect bounds;
- short procID;
- short filler;
- Boolean visible;
- Boolean goAway;
- long refCon;
- Str255 title;
- }
- WindTemplate, *WindTemplatePtr, **WindTemplateHdl;
-
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #endif